package com.eastfair.pay.enums;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 发票申请
 * </p>
 *
 * @author gj
 * @date 2022-06-21
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "InvoiceApplyBusinessTypeEnum", description = "结算类型#{H:合同;J:结算单;G:管理费订单;D:服务订单;Z:证件订单;}-枚举")
public enum InvoiceApplyBusinessTypeEnum implements BaseEnum {

    /**
     * H="合同"
     */
    H("合同"),
    /**
     * J="结算单"
     */
    J("结算单"),
    /**
     * g="管理费订单"
     */
    G("管理费订单"),
    /**
     * d="服务订单"
     */
    D("服务订单"),
    /**
     * d="证件订单"
     */
    Z("证件订单"),
    /**
     * 违规罚款
     */
    VIOLATION_PUNISH("违规罚款"),
    /**
     * 加班申请
     */
    WORK_OVERTIME("加班申请"),

    /**
     * 保证金
     */
    BOND_AMOUNT("保证金订单"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static InvoiceApplyBusinessTypeEnum match(String val, InvoiceApplyBusinessTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static InvoiceApplyBusinessTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(InvoiceApplyBusinessTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "H,J", example = "H")
    public String getCode() {
        return this.name();
    }

}
